package com.leetcode.partition18;

import java.io.*;
import java.util.TreeMap;

/**
 * @author `RKC`
 * @date 2022/2/4 9:57
 */
public class LC1725可以形成最大正方形的矩形数目 {

    private static final BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
    private static final BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(System.out));

    public static void main(String[] args) throws IOException {
        int n = Integer.parseInt(reader.readLine());
        int[][] rectangles = new int[n][2];
        for (int i = 0; i < n; i++) {
            String[] ss = reader.readLine().split(" ");
            int a = Integer.parseInt(ss[0]), b = Integer.parseInt(ss[1]);
            rectangles[i] = new int[]{a, b};
        }
        writer.write(countGoodRectangles(rectangles) + "\n");
        writer.flush();
    }

    public static int countGoodRectangles(int[][] rectangles) {
        TreeMap<Integer, Integer> map = new TreeMap<>((o1, o2) -> Integer.compare(o2, o1));
        for (int[] rectangle : rectangles) {
            int a = Math.min(rectangle[0], rectangle[1]);
            map.put(a, map.getOrDefault(a, 0) + 1);
        }
        return map.firstEntry().getValue();
    }
}
